home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
CUGUK
/
C005.ZIP
/
AMORTIZ
/
AMORTIZ3.C
< prev
next >
Wrap
Text File
|
1990-01-19
|
2KB
|
95 lines
/********************************************************************
* C Users Group (U.K) C Source Code Library File CUGLIB.005 *
* Inquiries to: M. Houston, 36 Whetstone Clo. Farquhar Rd. *
* Edgbaston, Birmingham B15 2QN ENGLAND *
********************************************************************
* File name: amortiz3.c
* Program name:
* Source of file: The Public Domain Software Library.
* Purpose: interest rate calculations.
* Changes: <who what when & why major changes have been made>
********************************************************************/
/*
amount = starting balance
balance = remaining balance
rate = interest rate per period
rate1 = interest rate per year
payment = monthly payment
principal = payment to principle
interest = payment of interest per period
*******************************************************/
/* declare variables */
float amount;
float balance =0;
float rate1;
float rate;
float payment;
float principal = 0;
float interest = 0;
/* ************************** */
interest1() /* call compute and print results */
{
balance = amount;
int x =0;
printf(" payment interest principal balance\n");
while (balance >0) /* call compute and print results */
{
compute();
printf("%8.2f %8.2f %8.2f %8.2f %d\n",payment, interest,
principal, balance, ++x);
line();
if (x%12 ==0) /* pause every 12 payments */
{
printf("press return");
getchar();
}
}
}
/* compute balance */
compute()
{
if (balance > payment)
{
interest = balance * rate;
principal = payment - interest;
balance = balance - principal;
return (interest);
return (principal);
return (balance);
}
else
{
interest = balance * rate;
payment = balance + interest;
principal = payment - interest;
balance = balance - principal;
return (interest);
return (payment);
return (principal);
return (balance);
}
}
line()
{
int x = 0;
while (x++<=79)
printf("-");
}